package com.bdqn;

import java.lang.reflect.Field;

public class Test_2 {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchFieldException {
        Class clz = Class.forName("com.bdqn.Person");
        Object newInstance = clz.newInstance();

        Field name = clz.getDeclaredField("name");
        name.setAccessible(true);

        System.out.println("赋值前的name: " + name.get(newInstance));

        name.set(newInstance, "New Person");

        System.out.println("赋值后的name: " + name.get(newInstance));


    }

}
